﻿namespace ZFramework.Runtime
{
    public class PacketMessage : IReference
    {
        public int ReqId
        {
            get;
            private set;
        }

        public string MsgName
        {
            get;
            private set;
        }

        public byte[] Data
        {
            get;
            private set;
        }

        public static PacketMessage Create(int reqId, string msgName, byte[] data)
        {
            PacketMessage message = ReferencePool.Acquire<PacketMessage>();
            message.ReqId = reqId;
            message.MsgName = msgName;
            message.Data = data;
            
            return message;
        }

        public void Clear()
        {
            ReqId = 0;
            MsgName = string.Empty;
            Data = null;
        }
    }
}